package com.wind.trademark.bill.controller;


import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wind.trademark.bill.model.BlBill;
import com.wind.trademark.bill.model.BlBillDetail;
import com.wind.trademark.bill.model.BlFee;
import com.wind.trademark.bill.service.BillService;
import com.wind.trademark.bill.vo.BillInfoVo;
import com.wind.trademark.bill.vo.BillVo4Detail;
import com.wind.trademark.bill.vo.BillVo4Fee;
import com.wind.trademark.common.exception.TmException;
import com.wind.trademark.common.vo.PageBean;
import com.wind.trademark.common.vo.PageParam;

@Controller
public class BillController {
	@Autowired
	private BillService  billService ;

	private static final Log log = LogFactory.getLog(BillController.class);

	
	@RequestMapping
	public @ResponseBody  BlBill loadBlBill(Long id){
		return billService.loadBill(id);
	}
	
	@RequestMapping
	public @ResponseBody  BlBillDetail loadBlBillDetail(Long id){
		return billService.loadBillDetail(id);
	}
	
	@RequestMapping
	public @ResponseBody  BlFee  loadBlFee(Long id){
		return billService.loadBlFee(id);
	}
	
	@RequestMapping
	public @ResponseBody
	PageBean queryBill(PageParam pageParam,
			@RequestParam Map<String, Object> params) {

		PageBean pageBean = billService.queryBill(pageParam, params);
		return pageBean;
	}

	@RequestMapping
	public @ResponseBody
	PageBean queryBillDetail(PageParam pageParam,
			@RequestParam Map<String, Object> params) {

		PageBean pageBean = billService.queryBillDetail(pageParam, params);
		return pageBean;
	}
	@RequestMapping
	public @ResponseBody
	PageBean queryFee(PageParam pageParam,
			@RequestParam Map<String, Object> params) {

		PageBean pageBean = billService.queryFee(pageParam, params);
		return pageBean;
	}
	@RequestMapping
	public @ResponseBody
	BlBill saveOrUpdateBill(BlBill blBill) {
		return billService.saveOrUpdateBill(blBill);

	}
	@RequestMapping
	public @ResponseBody
	BlBillDetail saveOrUpdateBlBillDetail(BlBillDetail blBillDetail) {
		return billService.saveOrUpdateBlBillDetail(blBillDetail);

	}
	@RequestMapping
	public @ResponseBody
	BlFee saveOrUpdateBlFee(BlFee blFee) {
		return billService.saveOrUpdateBlFee(blFee);

	}
	@RequestMapping
	public @ResponseBody
	Long[] deleteBillDetails(Long[] ids) {
		billService.deleteBillDetails(Arrays.asList(ids));
		 return ids;
	}
	@RequestMapping
	public @ResponseBody
	Long[] deleteFees(Long[] ids) {
		billService.deleteFees(Arrays.asList(ids));
		 return ids;
	}
	
	@RequestMapping
	public @ResponseBody
	Long deleteBillDetail(Long id) {
		billService.deleteBillDetail(id);
		 return id;
	}
	@RequestMapping
	public @ResponseBody
	Long deleteBill(Long id) throws TmException {
		billService.deleteBill(id);
		 return id;
	}
	@RequestMapping
	public @ResponseBody
	List<BillVo4Fee> queryBillVoAndItsFeeVo(Long taskId) {
		return billService.queryBillVoAndItsFeeVo(taskId);

	}
	@RequestMapping
	public @ResponseBody
	List<BlBillDetail> queryBlBillDetailByBillId(Long billId) {
		return billService.queryBlBillDetailByBillId(billId);

	}
	@RequestMapping
	public @ResponseBody
	List<BlBill> queryBlBillByTaskId(Long taskId) {
		return billService.queryBlBillByTaskId(taskId);

	}	
	@RequestMapping
	public @ResponseBody
	List<BlFee> queryBlFeelByBillId(Long billId) {
		return billService.queryBlFeelByBillId(billId);

	}
	@RequestMapping
	public @ResponseBody
	List<BillVo4Detail> queryBillVoAndItsDetailVo(Long taskId) {
		return billService.queryBillVoAndItsDetailVo(taskId);

	}
	@RequestMapping
	public @ResponseBody
	BillInfoVo getBillInfo(Long billId) {
		return billService.getBillInfo(billId);

	}
	
	@RequestMapping
	public @ResponseBody
	Double getTotalAmountByBillId(Long billId) {
		return billService.getTotalAmountByBillId(billId);
	}
	@RequestMapping
	public @ResponseBody
	Double getPaidAmountByBillId(Long billId) {
		return billService.getPaidAmountByBillId(billId);
	}
	@RequestMapping
	public @ResponseBody
	BlBill changeBillStatus(Long billId,String status) throws TmException {
		return billService.changeBillStatus(billId,status);
	}
	
}
